package com.egao.oa.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
//import com.egao.oa.mapper.JournalMapper;
import com.egao.oa.entity.Journal;
import com.egao.oa.service.JournalService;
import org.springframework.stereotype.Service;
import com.egao.oa.biz.JournalBiz;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * 日记服务实现类
 * @author : Doman
 * @date : 2021-03-22 15:52:42
 * @version ：1.0
 */
@Service
public class JournalServiceImpl /*extends ServiceImpl<JournalMapper, Journal> */implements JournalService {

	@Autowired
	private JournalBiz journalBiz;

    /**
    @Override
    public PageResult<Journal> listPage(PageParam<Journal> page) {
        List<Journal> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<Journal> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */

    @Override
    public JsonResult list(PageResult2<T> page, Journal journal, User loginUser)  throws Exception{
        return journalBiz.list(page,journal,loginUser);
    }

    @Override
    public List<Journal> list(Journal journal, User loginUser) {
        return journalBiz.list(journal,loginUser);
    }

    @Override
    public JsonResult getById(Journal journal) {
        return JsonResult.ok().setData(journalBiz.getById(journal));
    }

    @Transactional
    @Override
    public JsonResult save(Journal journal, User loginUser) {
        if (journalBiz.save(journal, loginUser)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @Transactional
    @Override
    public JsonResult update(Journal journal, User loginUser) {
        if (journalBiz.update(journal, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Transactional
    @Override
    public JsonResult remove(Journal journal, User loginUser) {
        if (journalBiz.remove(journal, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
